package org.example;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
public class SecurityHttpBasicConfiguration {
  @Bean
  public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception{
      //所有请求都需要认证，认证方式HTTP Basic
      http.authorizeHttpRequests((auth) ->{
          auth.anyRequest().authenticated();
      }).httpBasic(Customizer.withDefaults());
      return http.build();
  }
}
